<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <link rel="stylesheet"href="__STATIC__/layui1/css/layui.css">
    <link rel="stylesheet" href="__STATIC__/css/page.css">
</head>
<body class="layui-layout-body" >
<div class="layui-layout layui-layout-admin">
    {include file="public/head"}
    <div class="layui-body">
        <!-- 内容主体区域 -->
        <div style="padding: 15px;">

            <form class="layui-form-item" method="get" action="{:url('news/index')}">
                <div class="demoTable">
                    搜索标题：
                    <div class="layui-inline">
                        <input value="<?=empty($_REQUEST['search'])?'':$_REQUEST['search']?>"  class="layui-input" name="search" id="demoReload" autocomplete="off" placeholder="请输入查询内容" >
                    </div>
                    <select name="type_id" lay-verify="required" style="height: 40px;width: 100px">
                        <option value="">请选择分类</option>
                        <?php
                        $type_id=empty($_REQUEST['type_id']) ? 0:$_REQUEST['type_id'];
                        foreach ($types as $item){
                            if ($type_id==$item['id']){
                                echo "<option selected value='$item[id]'>$item[name]</option>";
                            } else {
                                echo "<option  value='$item[id]'>$item[name]</option>";
                            }
                        }
                        ?>
                    </select>
                    <input type="submit" class="layui-btn" value="搜索">
                </div>
            </form>

            <table class="layui-table"lay-filter="demo" style="width: 100%;height: 480px">
                <thead>
                <tr>
                    <th>编号</th>
                    <th>标题</th>
                    <th>内容</th>
                    <th>发布日期</th>
                    <th>图片</th>
                    <th>分类</th>
                    <th>发布人</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <?php
                foreach ($list as $item){
                    $type_name=$item['type']['name'];
                    echo"
                    <tr style=\"height: 100px\">
                    <td>$item[id]</td>
                    <td>$item[title]</td>
                    <td>$item[content]</td>
                    <td>$item[create_time]</td>
                    <td><img src=\"__UPLOADS__/$item[img]\"></td>
                    <td>$type_name</td>
                    <td>$item[user_id]</td>
                     <td>
                     <a  href=\"".url('news/edit',['id'=>$item['id']])."\"
                        class=\"layui-btn layui-btn-md\" lay-event=\"edit\">编辑</a>  
                     <a  href=\"".url('news/del', ['id' => $item['id']]) . "\"
                                class=\"layui-btn layui-btn-danger layui-btn-md\">删除
                        </a>
                    </td>
                </tr>
                    ";
                }
                ?>
                </tbody>
            </table>
            {$list|raw}

        </div>
    </div>

    <div class="layui-footer">
        <!-- 底部固定区域 -->
        © layui.com - 底部固定区域
    </div>
</div>

</body>
<script src="__STATIC__/layui1/layui.js"></script>
<script>
    layui.use(['element','layer','form'], function() {
        var element = layui.element;
        var layer = layui.layer;


        });
</script>

</html>